class SingletonLazy{
    private int x = 10;
    private int y = 20;
    public void fuc(){
        System.out.println(x + y);
    }
    private volatile static SingletonLazy instance = null;
    private static Object lock = new Object();

    public static SingletonLazy getInstance(){
        if (instance == null){
            synchronized (lock){
                if(instance == null){
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }
    private SingletonLazy(){

    }
}


public class Demo2 {
    public static void main(String[] args) {
       SingletonLazy singletonLazy = SingletonLazy.getInstance();
       singletonLazy.fuc();
    }
}
